//
//  FtToApplyForBusinessViewController.m
//  Feast
//
//  Created by 胡光健 on 2017/8/23.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "FtToApplyForBusinessViewController.h"
#import "FtToApplyForBusinessBanner.h"
#import "OderStateViewController.h"
#import "FtToApplyForCell.h"
#import "FtBusinessInformationController.h"

@interface FtToApplyForBusinessViewController ()
@property(nonatomic,strong)FtToApplyForBusinessBanner * bannerView;
@property(nonatomic,strong)NSArray * textArr;
@property(nonatomic,strong)NSArray * textDetailArr;
@end

@implementation FtToApplyForBusinessViewController

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[self.navigationController.navigationBar subviews] objectAtIndex:0].alpha = 0;
}
-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[self.navigationController.navigationBar subviews] objectAtIndex:0].alpha = 1;
}
-(NSArray *)textArr {
    if (!_textArr) {
        _textArr = @[@[@"商户信息",@"商户编号",@"商户名",@"商户负责人",@"联系电话",@"商户类型"],@[@"关于盛宴商户端",@"联系我们",@"设置"]];
    }
    return _textArr;
}
-(NSArray *)textDetailArr {
    if (!_textDetailArr) {
        _textDetailArr = @[@[@"",@"SJ001",@"XX商家",@"阳永江",@"15762536368",@"甜品"],@[@"",@"",@""]];
    }
    return _textDetailArr;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.rightNavImageName = @"Shape";
    self.automaticallyAdjustsScrollViewInsets = NO;
}
-(void)configTableView {
    self.needRefresh = YES;
    self.tableViewStyle = UITableViewStylePlain;
    [super configTableView];
    self.tableView.frame = CGRectMake(0, -64, mScreenWidth, mScreenHeight-44);
    self.tableView.tableHeaderView = [self configBannerView];
    [self.tableView registerCellByNibName:@"FtToApplyForCell"];

}
-(UIView *)configBannerView {
    WeakSelf
    self.bannerView = [[FtToApplyForBusinessBanner alloc]initWithFrame:CGRectMake(0, 0, mScreenWidth, 280)];
    self.bannerView.statueBtnBlock = ^(NSInteger tag) {
        OderStateViewController *vc = [[OderStateViewController alloc]init];
        if (tag==0) {//待接单
            vc.navTitle = @"待接单";
            vc.type = treatOderState;
        }else if (tag==1) {//待配送
            vc.navTitle =@"待配送";
            vc.type = treatDeliveryState;
        }else if (tag==2) {//已完成
            vc.navTitle = @"已完成";
            vc.type = finishState;
        }else if (tag==3) {//退款
            vc.navTitle = @"退款";
            vc.type = refundState;
        }
        [weakSelf.navigationController pushViewController:vc animated:YES];
    };
    return self.bannerView;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 45;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.textArr[section] count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    FtToApplyForCell * cell = [tableView dequeueReusableCellWithIdentifier:@"FtToApplyForCell"];
    if (indexPath.section==0&& indexPath.row==0) {
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.titleLabel.text = self.textArr[indexPath.section][indexPath.row];
    cell.contetLabel.text = self.textDetailArr[indexPath.section][indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0 && indexPath.row ==0) {
        FtBusinessInformationController * VC = [[FtBusinessInformationController alloc]init];
        VC.navTitle = @"商户信息";
        [self.navigationController pushViewController:VC animated:YES];
    }
}
#pragma mark -- 消息
-(void)didClickRightNavAction {
    FtMessageViewController * vc = [[FtMessageViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
@end
